Avoid SelectableGroups deprecation warning#5238
Open
HasanTasdiq wants to merge 3 commits into
Open
Conversation
Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
herin049
reviewed
May 20, 2026
Assisted-by: OpenAI Codex
herin049
reviewed
May 21, 2026
| return eps | ||
| # Handle Python 3.10 SelectableGroups (dict-like) | ||
| return EntryPoints(ep for group_eps in eps.values() for ep in group_eps) | ||
| with warnings.catch_warnings(): |
Contributor
There was a problem hiding this comment.
Sorry for going back here - I just realized that this context manager is not thread safe. Just to be extra cautious, it's probably best to go back to calling select on each group like you had previously, but still without the conditional using "hasattr".
herin049
reviewed
May 22, 2026
| @@ -0,0 +1 @@ | |||
| Avoid import-time deprecation warnings on Python 3.10 and 3.11. | |||
Contributor
There was a problem hiding this comment.
You need to add package name here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5231
Summary
SelectableGroupswithout using its deprecated dict interface.DeprecationWarningas an error while convertingSelectableGroups.Why
On Python 3.10 and 3.11,
importlib.metadata.entry_points()can returnSelectableGroups. Calling its dict-likevalues()emits aDeprecationWarning, which breaks users running with warnings as errors when importingopentelemetry.context.Testing
python3 -m pytest opentelemetry-api/tests/util/test__importlib_metadata.py- passedpython3 -W error -c 'import opentelemetry.context'- passed\n- Ran:python3 -W error -m pytest opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n- Ran:python3 -m ruff check opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n- Ran:python3 -m py_compile opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py opentelemetry-api/tests/util/test__importlib_metadata.py- passed\n\n## Notes\n- Full tox/precommit not run locally becauseuvandtoxare not installed in this shell.\n